<template>
  <YkiteFullScreenContainer
      :class="{'container-bg-new': pageInfo.pageTemplate == 2, 'container-bg-old' : pageInfo.pageTemplate == 1}"
      :style="{ 'background-image': pageInfo.background.url?`url(${pageInfo.background.url})`:'' }">
    <div class="header-view"
         :class="{'header-bg-new':pageInfo.pageTemplate == 2, 'header-bg-old' : pageInfo.pageTemplate == 1}">
      <header-bi :title="pageInfo.pageName" :headerData="pageInfo.header" v-if="pageInfo.header"
                 :pageTemplate="pageInfo.pageTemplate"></header-bi>
    </div>
    <div class="midden-view">
      <template-old v-if="pageInfo.pageTemplate == 1" :pageInfo="pageInfo"/>
      <template-new v-if="pageInfo.pageTemplate == 2" :pageInfo="pageInfo"/>
    </div>
    <div class="footer-view">
      <footer-bi/>
    </div>
  </YkiteFullScreenContainer>
</template>

<script setup lang="ts">
import {useRoute} from "vue-router";
import {onMounted, ref} from "vue";
import {getBiInfo} from "@/api/manage/station";
import TemplateOld from '@/views/biOld/one/index.vue';
import TemplateNew from '@/views/bi/one/index.vue';
import HeaderBi from "@/views/bi/component/headerBi.vue";
import FooterBi from "@/views/bi/component/footerBi.vue";
import {notification} from "@/hooks/my-design";

interface IRouteQuery {
  stationId: string,
  isPre: string,
}

const route: any = useRoute();

const pageInfo = ref<any>({
  pageTemplate: '0',
  background: {
    type: "image",
    url: ''
  },
  cardList: {
    bottomList: [],
    leftTop: [],
    rightTop: []
  }
})

const getInfo = async () => {
  try {
    const {stationId, isPre}: IRouteQuery = route.query;
    const res: any = await getBiInfo({stationId, isPre});
    if (res.code === 200 && !res.data.code) {
      pageInfo.value = res.data;
    } else {
      notification(res.data)
    }
  } catch (e) {
    console.log(e, '大屏模板报错')
  }
}

onMounted(() => {
  getInfo()
})
</script>

<style lang="less" scoped>
.container-bg-new {
  background-image: url("@/assets/bi/background.png");
}

.container-bg-old {
  background-image: url("@/assets/biTow/background.png");
}

.header-bg-new {
  background-image: url("@/assets/bi/navbar.png");
  background-repeat: no-repeat;
  background-position: center;
  background-size: 100% 100%;
}

.header-bg-old {
  background-image: url("@/assets/bi/navbarOld.png");
  background-repeat: no-repeat;
  background-position: bottom;
}

#ykite-full-screen-container {
  background-size: 100% 100%;
  background-repeat: no-repeat;
  color: #FFFFFF;
  font-family: Source Han Sans;
  display: flex;
  flex-direction: column;
  justify-content: space-between;
  position: relative;

  .header-view {
    padding: 0 32px;
    height: 80px;
    font-size: 28px;
  }

  .midden-view {
    height: calc(100% - 160px);
  }

  .footer-view {
    height: 40px;
  }
}
</style>
